package com.gdsdxy.bookshop.service;

import com.gdsdxy.bookshop.dao.BookMapper;
import com.gdsdxy.bookshop.dao.CartMapper;
import com.gdsdxy.bookshop.dao.OrderMapper;
import com.gdsdxy.bookshop.dao.UserMapper;
import com.gdsdxy.bookshop.dto.CartDto;
import com.gdsdxy.bookshop.pojo.Book;
import com.gdsdxy.bookshop.pojo.Cart;
import com.gdsdxy.bookshop.pojo.Order;
import com.gdsdxy.bookshop.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CartService {
    @Autowired
    OrderMapper orderMapper;
    @Autowired
    UserMapper userMapper;
    @Autowired
    CartMapper cartMapper;

    @Autowired
    BookMapper bookMapper;
    /**
     * 功能描述：在购物车表中Cart添加一条记录，返回添加记录的主键
     * author:黄培强
     * @param cart 顾客标识
     * @return 返回新增记录的主键ID
     */
    public Integer create(Cart cart){
        cartMapper.insert(cart);
        return cart.getCartid();
    }
//    public CartDto detail(Integer userid,Integer bookid){
//        CartDto cartDto= new CartDto();
//        cartDto.setUserid(userid);
//        User user = userMapper.selectById(userid);
//        cartDto.setBookid(bookid);
//        //在cart表中查找bookid=bookid的书籍信息
//        Book book = bookMapper.selectById(bookid);
//       / Cart cart = orderMapper.selectById(orderid);
//    }
}
